﻿
/**
 * TRS分页方法
 * @param _nPageCount 总页数
 * @param _nCurrIndex 当前页
 * @param _sPageName 文件名
 * @param _sPageExt 文件后缀
 * @param _nRecordCount 记录数
 */
function createPageHTML (_nPageCount, _nCurrIndex, _sPageName, _sPageExt, _nRecordCount) {
    if (_nPageCount && _nPageCount > 1) {
        document.write('<a href="' + _sPageName + '.' + _sPageExt + '">首页</a>');
        var nCurrIndex = _nCurrIndex || 0;
        if (nCurrIndex == 0) {
            //document.write('<a href="#none">上一页</a>');
            //document.write('<a href="#none" class="current">1</a>');
        } else {
            if (nCurrIndex == 1) {
                document.write('<a href="' + _sPageName + '.' + _sPageExt + '">上一页</a>');
            } else {
                document.write('<a href="' + _sPageName + '_' + (nCurrIndex - 1) + '.' + _sPageExt + '">上一页</a>');
            }
            //document.write('<a href="' + _sPageName + '.' + _sPageExt + '">1</a>');
        }
        for (var i = 0; i < _nPageCount; i++) {
            if (10 < _nPageCount && (i < (_nCurrIndex - 5) || i > (_nCurrIndex + 5))) {
                continue;
            }
            if (i == 0) {
                document.write('<a href="' + _sPageName + '.' + _sPageExt + '"' + ((nCurrIndex == i) ? ' class="current" onclick="return false;"' : '') + '>' + (i + 1) + '</a>');
            } else {
                document.write('<a href="' + _sPageName + '_' + i + '.' + _sPageExt + '"' + ((nCurrIndex == i) ? ' class="current" onclick="return false;"' : '') + '>' + (i + 1) + '</a>');
            }
        }
        if (nCurrIndex === (_nPageCount - 1) && _nPageCount > 1) {
            //document.write('<a href="#none">下一页</a>');
        } else {
            document.write('<a href="' + _sPageName + '_' + (nCurrIndex + 1) + '.' + _sPageExt + '">下一页</a>');
        }
        document.write('<a href="' + _sPageName + '_' + (_nPageCount - 1) + '.' + _sPageExt + '">末页</a>');
    }else if (_nRecordCount == '${RECORD_COUNT}'){
		_nRecordCount = 0 ;
    }
    
    document.write('<a href="#none" onclick="return false;">共 ' + _nPageCount + ' 页 ' + _nRecordCount + ' 条</a>');
}